<?php
/*
Copyright (C) 2009 de Flotte Maxence

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
?>
<?php
include_once './ZzL/generation.php';

function genZzG2($ZzS,$FileZzS) {

	include_once './ZzO/std/Boot.php';
	include_once './ZzO/std/Main.php';

	ob_start();
	eval(createStaticpuZZle2($ZzS));
	$gen = ob_get_contents();
	ob_end_clean();

	$open = fopen('./ZzG/'.$FileZzS.'.php', "w");
	fwrite($open, $gen);
	fclose($open);

	include './ZzG/'.$FileZzS.'.php';
}

function createStaticpuZZle2($ZzS) {

	$return = '';
//	 $return = "<?php \n";
	//$return .= '//$GLOBALS[\'MySql\'] = new mysqli($GLOBALS[\'Serveur\'], $GLOBALS[\'Login\'], $GLOBALS[\'PassWord\'], $GLOBALS[\'DB\']);'."\n";

	$ZzS = str_replace("\n","",$ZzS);
	$ZzS = str_replace("\r","",$ZzS);
	$return .= '$page = new page("page");'."\n";
	if(@$noStructure) '$Page->setNoStructure(\'true\');';
	//$ListObject = Array('page'=>array('main'=>$Page));
	$Cursor = 0;
	$_ZzO = array();

	while($Cursor < strlen($ZzS))
		$return .= convertInstruction($ZzS,$Cursor,$LastObjectCall, $_ZzO);

	$return .= 'echo $page->buildStaticpuZZle();'."\n";
	$return .= '$GLOBALS[\'noCache\'] = $page->noCache;'."\n";
	//$return .= '//$GLOBALS[\'MySql\']->close();'."\n";
/*	 $return .= '?>';*/
	return $return;
}

?>